﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ShootThemUp
{
   

    public class Enemy : Acteur
    {
        //public static TimeSpan LIMITE_ENEMY = new TimeSpan(0, 0, 0, 1, 0);
        public static TimeSpan DateDernierEnemy { get; set; }
        public TypeEnnemi typeEnemy;
        public int NbVies { get; set; }
        
        public Enemy(Vector2 position, TypeEnnemi type) : base(position, type.Texture, type.Vitesse)
        {
            typeEnemy = type;
            NbVies = typeEnemy.NbVies;
        }

        public void update(GameTime gametime)
        {
            Position = new Vector2(Position.X + Vitesse.X, Position.Y + Vitesse.Y);
            if (!Controleur.estDansCadre(Controleur.CADRE_JEU, Rectangle))
                EstSupprimable = true;
        }

        //public static Enemy generateEnemyRandomX()
        //{
        //    Random random = new Random();
        //    int posX = random.Next(450);
        //    return new Enemy(new Vector2(posX, 5));
        //}

        public TypeBonus Destruction()
        {
            Random rand = new Random();
            foreach (KeyValuePair<TypeBonus, int> proba in typeEnemy.ProbablilitesBonus)
            {
                int probabi = proba.Value;
                int random = rand.Next(100);
                if (probabi > random)
                    return proba.Key;
            }
            return TypeBonus.Rien;
        }
    }
}
